package com.yincai.carefreewater.tool;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;

import java.io.Serializable;

/**
 * Created by $zhangke on 2017/5/16.
 *
 * 跳转工具类
 */

public class JumpTool {
    /**
     * @param context
     * @param T
     * 单一跳转
     */
    public  static void jump(Context context, Class T){
        Intent intent =new Intent(context,T);
        context.startActivity(intent);
    }

    /**
     * @param context
     * @param T
     * @param name
     * @param value
     *
     * 传递一个参数
     */
    public static void jump(Context context, Class T, String name, Object value){
        Intent intent =new Intent(context,T);
        intent.putExtra(name,(Serializable) value);
        context.startActivity(intent);
    }

    /**
     * @param context
     * @param T
     * @param request
     *
     * 带返回值启动
     */
    public static void jump(Context context, Class T, int request){
        Intent intent =new Intent(context,T);
        ((AppCompatActivity)context).startActivityForResult(intent,request);
    }

    /**
     * @param context
     * @param T
     * @param key
     * @param value
     * 传递多个参数
     */
    public static void jump(Context context, Class T, String[] key, Object[]value){
        Intent intent =new Intent(context,T);
         for (int i=0;i<key.length;i++){
             intent.putExtra(key[i],(Serializable) value[i]);
          }
        context.startActivity(intent);
    }



}
